<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户列表</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
        }
        th, td {
            padding: 10px;
            border: 1px solid #ddd;
            text-align: left;
        }
        th {
            background-color: #f4f4f4;
        }
    </style>
</head>
<body>
    <h1>用户列表</h1>
    <table id="usersTable">
        <thead>
            <tr>
                <th>ID</th>
                <th>用户名</th>
                <th>邮箱</th>
            </tr>
        </thead>
        <tbody>
            <!-- 用户数据将动态插入到这里 -->
        </tbody>
    </table>

    <script>
        // 获取用户数据并渲染表格
        fetch('/users/')
            .then(response => response.json())
            .then(data => {
                const tbody = document.querySelector('#usersTable tbody');
                data.users.forEach(user => {
                    const row = document.createElement('tr');
                    row.innerHTML = `
                        <td>${user.id}</td>
                        <td>${user.username}</td>
                        <td>${user.email}</td>
                    `;
                    tbody.appendChild(row);
                });
            })
            .catch(error => console.error('获取用户数据失败:', error));
    </script>
</body>
</html>